﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace BanSupport
{
    public class RotateContinueAction : BaseAction
    {

        public Fix64 rotateSpeed;
        public Fix64 during;

        private Fix64 curTime;

        public RotateContinueAction(BaseObject obj, Fix64 rotateSpeed, Fix64 during, Action completeAction = null)
            : base(obj, completeAction)
        {
            Change(rotateSpeed, during);
        }

        public void Change(Fix64 rotateSpeed, Fix64 during)
        {
            this.rotateSpeed = rotateSpeed;
            this.during = during;
            this.curTime = Fix64.Zero;
        }

        public override bool Update()
        {
            base.Update();
            curTime += GameLogic.Instance.deltaTime;
            var process = Fix64.Clamp01(curTime / during);
            obj.rotation += GameLogic.Instance.deltaTime * this.rotateSpeed;
            if (process >= Fix64.One)
            {
                TriggerCompleteAction();
                return true;
            }
            else
            {
                return false;
            }
        }
    }

}
